package com.itheima;

public class TestLambda {
    public static void main(String[] args) {
        TestA();
        TestB();
        TestC();
        TestD();
    }

    public  static  void  TestD(){
        D D1 = new D() {
            @Override
            public int max(int a, int b) {
                return Math.max(a,b);
            }
        };

        D D2 = (a, b) -> a>b ? a : b;

        D D3 = Math::max;
        int max = D3.max(10,20);
        System.out.println(max);

    }

    public static void TestC() {
        C c1 = new C() {
            @Override
            public String show(String name) {
                return "name" + name;
            }
        };
        //2.创建C接口的Lambda表达式对象
        C c2 = name -> "name" + name;

        //3.创建C接口的方法引用对象
        C c3 = TestLambda::show4;
        String m = c3.show("赵鑫");
        System.out.println(m);

    }

    public static String show4(String name) {
        return "name" + name;
    }

    public static void TestB(){
        B b1 = new B(){
            @Override
            public void show(String name) {
                System.out.println(name);
            }
        };
        //2.创建B接口的Lambda表达式对象
        B b2 = (name) -> System.out.println(name);
        //3.创建B接口的方法引用对象
        B b3 = System.out::println;
        b3.show("张三");

    }
    public static void TestA() {
        A a1 = new A() {
            @Override
            public void show(String name, int age) {
                System.out.println(name+','+age);
            }
        };
        //2.创建A接口的Lambda表达式对象
        A a2 = (name, age) -> System.out.println("name = " + name + "age = " + age);
        //创建A接口的方法引用对象
        A a3 = TestLambda::show2;
        a3.show("赵鑫",18);
    }

    public static void show2(String name, int age) {
        System.out.println(name+','+age);
    }

}